﻿#include <iostream>
#include <fstream>
using namespace std;

int Son(char* a, bool* b, int n, int count);
int main() {
	char* a = new char[26];
	bool* b = new bool[26];
	for (int i = 0; i < 26; i++)
		a[i] = 'a' + i;
	for (int i = 0; i < 26; i++)
		b[i] = true;

/*	cout << "请输入1~26的整数：" << "\n";
	int n;
	while (cin >> n) {
		if (n < 1 || n>26) {
			cout << "WRONG!"<<"\n";
			continue;
		}
		break;
	}*/
	int n;
	ifstream read;
	read.open("d://input.txt");
	read >> n;
	read.close();
	if (n < 1 || n>26) {
		cout << "WRONG!" << "\n";
		return 0;
	}


	Son(a, b, n, 0);
	delete[] a;
	delete[] b;
	return 0;
}
int Son(char* a, bool* b, int n ,int count) {
	count++;
	if (count > n) {
		int first = 0;
		cout << "{";
		while (1) {
			if (b[first] == 0 && first < n - 1)
				first++;
			else if (b[first] == 1) {
				cout << a[first];
				break;
			}
			else if (first = n ) {
				cout <<"}"<< endl;
				return 0;
			}
		}
		for (int i = first+1; i < count - 1; i++) {
			if (b[i]) {
				cout << " " << a[i];
			}
		}
		cout <<"}"<< endl;
		return 0;
	}
	b[count - 1] = true;
	Son(a, b, n,count);
	b[count - 1] = false;
	Son(a, b, n,count);
	return 0;
}